package com.liu.springboot.activemq.demo.produce;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

@Component
public class Queue_Produce {

    @Autowired
    private JmsMessagingTemplate template;

    @Autowired
    private Queue queue;

    public void produceMsg() {
        template.convertAndSend(queue, "spirngboot整合activemq");
    }

    //间隔时间定投
    @Scheduled(fixedDelay = 3000)
    public void produceMsgScheduled() {
        template.convertAndSend(queue, "这是spirngboot整合activemq的定时任务");
        System.out.println("定时任务发表成功");
    }
}
